<?php
function query($sql){
    $connection = mysql_connect('localhost', 'root','vertrigo');
    mysql_select_db('tdc',$connection);
    
    $dulieu = mysql_query($sql);
    $data = array();
    while($row = mysql_fetch_assoc($dulieu)){
            $data[] = $row;
    }
    return $data;
}?>
<?php
function delete()
{
    if(isset($_POST['DEL'])){
        $connection = mysql_connect('localhost', 'root','vertrigo');
        mysql_select_db('tdc', $connection);
        $id = $_POST['ID'];
        $name = $_POST['NAME'];
        $sql = "delete from student where ID='$id'";
        $result = mysql_query($sql, $connection);          
    }
}?>
<?php
function add()
{
    if(isset($_POST['ADD'])){
        $connection = mysql_connect('localhost', 'root','vertrigo');
        mysql_select_db('tdc', $connection);
        $id = $_POST['ID'];
        $name = $_POST['NAME'];
        $sql = "insert into student value('$id','$name')";
        $result = mysql_query($sql, $connection);          
    }
}?>
<?php
function edit()
{
    if(isset($_POST['EDIT'])){
        $connection = mysql_connect('localhost', 'root','vertrigo');
        mysql_select_db('tdc', $connection);
        $id = $_POST['ID'];
        $name = $_POST['NAME'];
        $sql = "UPDATE student SET NAME='$name' WHERE ID='$id'";
        $result = mysql_query($sql, $connection);          
    }
}?>
    